package com.creatingrevolutions.vbukit.lib;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

/**
 * Created by warodri on 7/26/13.
 */
public class IconUtils
{
	public static void addShortcut(
			Context context, String shortcutName, int icon, Activity activity)
	{
		// Adding shortcut for MainActivity
		// on Home screen
		Intent shortcutIntent = new Intent(context, activity.getClass());
		
		shortcutIntent.setAction(Intent.ACTION_MAIN);
		
		Intent addIntent = new Intent();
		addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
		addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutName);
		addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
				Intent.ShortcutIconResource.fromContext(context, icon));
		
		addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
		context.sendBroadcast(addIntent);
	}
	
	public static void removeShortcut(
			Context context, String shortcutName, int icon, Activity activity)
	{
		// Deleting shortcut for MainActivity
		// on Home screen
		Intent shortcutIntent = new Intent(context, activity.getClass());
		shortcutIntent.setAction(Intent.ACTION_MAIN);
		
		Intent addIntent = new Intent();
		addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
		addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutName);
		
		addIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
		context.sendBroadcast(addIntent);
	}
	
}
